package com.kuqi.blog.controller;

import com.kuqi.blog.service.TagService;
import com.kuqi.blog.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author:kuqi
 * @createTime:2021/12/8 20:14
 * @description:
 */
@RestController
@RequestMapping("/tags")
public class TagsController {

    @Autowired
    private TagService tagService;

    //路劲/tags/hot
    @GetMapping("/hot")
    public Result hot(){
        //前6条
        int limit = 6;
        return tagService.hots(limit);
    }

    @GetMapping
    public Result findAll(){
        /**
         * 查询所有的文章标签
         */
        return tagService.findAll();
    }

    @GetMapping("detail")
    public Result detail(){
        return tagService.findAllDetail();
    }

    @GetMapping("detail/{id}")
    public Result findADetailById(@PathVariable("id") Long id){
        /**
         * 查询所有文章标签下所有的文章
         * @return
         */
        return tagService.findADetailById(id);
    }
}
